package com.axjy.web;

import com.axjy.pojo.*;
import com.axjy.service.ConfigService;
import com.axjy.service.InspectiontaskDetailService;
import com.axjy.service.LogsService;
import com.axjy.service.UserService;
import com.axjy.service.vo.Pager;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by l on 2018/3/6.
 */
@Controller
@RequestMapping("/sys/get")
public class getUserHandler {

    @Resource
    private UserService userService;

    @Resource
    private LogsService logsService;

    @Resource
    private ConfigService configService;

    @Resource
    private InspectiontaskDetailService inspectiontaskDetailService;

    @RequestMapping("/getUser")
    public String getUser(String userCode, Model model){
        User u=userService.getUser(userCode);
        System.out.println(u.getUserName());
        model.addAttribute("user",u);
        return "/sys/editUser";
    }

    @RequestMapping("/log")
    public String log(String userCode,Model model){
        List<Logs> list=logsService.search(userCode);
        model.addAttribute("l",list);
        return "/sys/log";
    }

    @RequestMapping("/getByDate")
    public String getByDate(String userCode,String startDate,String endDate,Model model){
        List<Logs> list=logsService.getByDate(userCode, startDate, endDate);
        model.addAttribute("l",list);
        return "/sys/log";
    }


    @RequestMapping("/getBy")
    public String getBy(String configCode,Model model){
        List<Systemconfig> list=configService.getByCode(configCode);
        model.addAttribute("l",list);
        return "sys/config";
    }

    @RequestMapping("/getSearch")
    public String getSearch(String lineCode,Model model){
        List<LineInfo> list=inspectiontaskDetailService.search(lineCode);
        model.addAttribute("l",list);
        return "config/xjzxhz1";
    }

    @RequestMapping("/getByCode")
    public String getByCode(String configCode,Model model){
        List<InspectiontaskDetail> list=inspectiontaskDetailService.getByCode(configCode);
        model.addAttribute("ll",list);
        return "config/xjzxhz1";
    }
}
